import { createRouter, createWebHistory } from 'vue-router';
import HomeView from '../views/HomeView.vue';
import EventHandleView from '../views/learn/EventHandle.vue';
import { inject } from 'vue';

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/AboutView.vue')
    },
    {
      path: '/list',
      name: 'list',
      component: () => import('../views/learn/List.vue')
    },
    {
      path: '/event-handle',
      name: 'event-handle',
      component: () => EventHandleView
    },
    {
      path: '/forms',
      name: 'forms',
      component: () => import('../views/learn/Forms.vue')
    },
    {
      path: '/webLg',
      name: 'webLg',
      component: () => import('../views/learn/weblg/WebLg.vue')
    },
    {
      path: '/threeFirst',
      name: 'threeFirst',
      component: () => import('../views/threeLearn/First.vue')
    },
    {
      path: '/threeLine',
      name: 'threeLine',
      component: () => import('../views/threeLearn/Line.vue')
    },
  ]
})

router.beforeEach((to, from) => {
  console.log('beforeEach' ,to);
  let h = inject('global');
  console.log(h);
})

router.beforeResolve((to, from) => {
  console.log('beforeResolve', to);
})

export default router
